<?php

namespace App\Http\Controllers\V1\Admin;

use App\Models\V1\SysOperateLogs;
use Illuminate\Http\Request;

class OperLogController extends BaseController
{
    /**
     * showdoc
     * @catalog 后台管理/日志管理
     * @title 日志管理列表
     * @description 日志管理列表
     * @method GET
     * @url https://www.juneng1.com/api/v1/admin/log
     * @return {"code":0,"data":{}}
     * @return_param code int 状态
     * @return_param message string 数据
     * @remark code:-1 错误,code:1 正常
     * @number 99
     */
    public function index(Request $request)
    {
        $query=SysOperateLogs::query();
        $pageSize=$request->input('pageSize',10);
        $order=$request->input('order','desc');
        $sort=$request->input('sort','id');

        if($request->filled('oper_name')){
            $query->where('oper_name','like','%'.$request->input('oper_name').'%');
        }
        if($request->filled('title')){
            $query->where('title',"like","%".$request->input('title')."%");
        }
        if($request->filled('begin_at')){
            $query->where('created_at','>=',$request->input('begin_at'));
        }
        if($request->filled('end_at')){
            $query->where('created_at','<=',$request->input('end_at'));
        }
        $query->orderBy($sort,$order);
        $data=$query->paginate($pageSize);
        return ajax_output(200,"成功",$data);
    }

}
